$(function(){

    $('.onlineTeam-redact').click(function(){

        var name = $(this).attr('data-name');
        var id = $(this).attr('data-id');
        var qq = $(this).attr('data-qq');


        $('#kefu-id').val(id);
        $('#kefu-username').val(name);
        $('#kefu-qq').val(qq);
    });

    /**
     *修改客服账号信息
     */
    $('#onlineTeam-save').click(function(){

        var id = $('#kefu-id').val();
        var username = $('#kefu-username').val();
        var qq = $('#kefu-qq').val();

        $.ajax({
            url: '/onlineTeamUpdateUserInfo',
            type: 'get',
            data: {
                id: id,
                username: username,
                qq: qq
            },
            timeout: 5000,
            dataType: 'json',
            success: function (data, textStatus, jqXHR) {
                if (data.error_code == 0) {
                    self.location='/onlineteam';
                    alert('客服信息修改成功');
                }else{
                    alert(data.message);
                }
            }

        })

    });

    /**
     * 删除账号信息
     */
    $('.onlineTeam-delete').click(function(){

        $_this = $(this);
        var id = $(this).attr('data-id');
        var username = $(this).attr('data-name');
        var qq = $(this).attr('data-qq');

        $.ajax({
            url: '/onlineTeamDelete',
            type: 'get',
            data: {
                id: id,
                username: username,
                qq: qq
            },
            timeout: 5000,
            dataType: 'json',
            success: function (data, textStatus, jqXHR) {
                if (data.error_code == 0) {
                    $_this.parent().parent().remove();
                    //self.location='/onlineteam';
                    alert('删除成功');
                }else{
                    alert(data.message);
                }
            }

        })
    });

});


//   客服提交审核

$(function(){

    $('.add-audit').click(function(){

        var qq = $(this).attr('data-qq');
        var time = $(this).attr('data-time');
        var id = $(this).attr('data-id');

        $('#hidden-qq').val(qq);
        $('#hidden-time').val(time);
        $('#hidden-id').val(id);


    });

    $('#bargain2').click(function(){

        if($('#bargain2').is(':checked'))
        {
            $('#bargain-pirce').hide();
            $('#bargain-date').hide();
            $('#kefu-date').hide();
        }

    });

    $('#bargain1').click(function(){

        if($('#bargain1').is(':checked'))
        {
            $('#bargain-pirce').show();
            $('#bargain-date').show();
            $('#kefu-date').show();
        }

    });





});